package com.hemi.rhet;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;

public class MainActivity extends TabActivity {
    
    public static final String TAG_ASK = "TAG_ASK";

    public static final String TAG_MY_QUES = "TAG_MY_QUES";

    public static final String TAG_ALL_QUES = "TAG_ALL_QUES";

    public static final String TAG_ON_RESOLVE = "TAG_ON_RESOLVE";

    public static final String TAG_RESOLVED = "TAG_RESOLVED";

    private String currentTabTag = TAG_ASK;

    private TabHost mTabHost;

	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mTabHost = getTabHost(); // The activity TabHost
        TabHost.TabSpec spec; // Resusable TabSpec for each tab
        Intent intent; // Reusable Intent for each tab
        intent = new Intent().setClass(this, AskActivity.class);
        intent.putExtras(getIntent());
        spec = mTabHost.newTabSpec(TAG_ASK)
                .setIndicator("我要提问")
                .setContent(intent);
        mTabHost.addTab(spec);
        
        intent = new Intent().setClass(this, WebViewDemo.class);
        intent.putExtras(getIntent());
        spec = mTabHost.newTabSpec(TAG_MY_QUES)
                .setIndicator("我的帖子")
                .setContent(intent);
        mTabHost.addTab(spec);
        
        intent = new Intent().setClass(this, WebViewDemo.class);
        intent.putExtras(getIntent());
        spec = mTabHost.newTabSpec(TAG_ALL_QUES)
                .setIndicator("所有帖子 ")
                .setContent(intent);
        mTabHost.addTab(spec);
        
        intent = new Intent().setClass(this, WebViewDemo.class);
        intent.putExtras(getIntent());
        spec = mTabHost.newTabSpec(TAG_ON_RESOLVE)
                .setIndicator("待解决")
                .setContent(intent);
        mTabHost.addTab(spec);
        
        intent = new Intent().setClass(this, WebViewDemo.class);
        intent.putExtras(getIntent());
        spec = mTabHost.newTabSpec(TAG_RESOLVED)
                .setIndicator("已解决")
                .setContent(intent);
        mTabHost.addTab(spec);
        
        mTabHost.setCurrentTabByTag(currentTabTag);
        intent.putExtras(getIntent());
        mTabHost.setOnTabChangedListener(new OnTabChangeListener() {
            @Override
            public void onTabChanged(String tabId) {
                currentTabTag = tabId;
            }
        });
    }

    @Override
    protected void onNewIntent(Intent intent) {
        setIntent(intent);
    }

}
